package com.xckj.teacher.ui.activity

import com.blankj.utilcode.util.ToastUtils
import com.xckj.teacher.R
import com.xckj.teacher.databinding.ActivityEditClassBinding
import com.xckj.teacher.framework.BaseActivity
import com.xckj.teacher.presenter.ClassPresenter
import com.xckj.teacher.util.ActivityMessenger
import com.xckj.teacher.util.get

class EditClassActivity : BaseActivity<ActivityEditClassBinding>() {

    private val presenter: ClassPresenter by lazy { ClassPresenter(this) }
    var id = ""

    override fun setStatusBarColor(): Int {
        return R.color.f7f8fa
    }

    inner class ProxyClick {
        fun back() {
            finish()
        }

        fun save() {
            var name = dataBinding.etClass.text.toString().trim()
            if (name.isNullOrEmpty()) {
                ToastUtils.showShort("请填写班级名称")
                return
            }
            presenter.editGrade(id, name) {
                ActivityMessenger.finish(this@EditClassActivity, "refresh" to "1")
            }
        }
    }

    override fun loadLayout(): Int {
        return R.layout.activity_edit_class
    }

    override fun initData() {
        dataBinding.click = ProxyClick()

        id = intent.get<String>("id").toString()
        dataBinding.tvSchool.text = "${intent.get<String>("school")}"
        dataBinding.etClass.setText("${intent.get<String>("class")}")
        dataBinding.tvGrade.text = "${intent.get<String>("grade")}"
        dataBinding.tvStudentNum.text = "${intent.get<String>("studentNum")}"
        dataBinding.tvVip.text = "${intent.get<String>("vipNum")}"

    }

    override fun setListener() {

    }

}